<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:a4j="http://richfaces.org/a4j"
                xmlns:rich="http://richfaces.org/rich"
                xmlns:fn="http://java.sun.com/jsp/jstl/functions">

    <style type="text/css">
        .formdata{
            border:1px solid #5f6f73;
            border-collapse:collapse;
        }
        .formdata input{
            width:90%;
            padding:2px 4px 2px 4px;
            margin:0;
            border:none;
            text-align: center;
        }
        .datatable tr:hover{
            background-color:#dfe7f2;
            color:#000000;
        }
        .pic{
            margin-bottom: -4px;
            margin-right: -2px;
            border:none;
        }
        .mainForm input{
            width: 200px;
        }
        .mainForm font{
        } 

        input[type='submit']{
            margin:3px 5px 3px 5px;
            padding:2px 5px 2px 5px;
        }

        .left{ 
            padding-right: 20px;
        }
        .right{
            vertical-align: top;
        }
    </style>
    <link href="./css/spreadsheet.css" rel="stylesheet" type="text/css" />
    <input type="hidden" id="transvalue" value="#{procureOrder.tag}"></input>
    <h:form id="stock">
        <rich:panel styleClass="content-hight">
            <f:facet name="header">
                <h:outputText value="主合同录入"/>
            </f:facet>
            <rich:messages/>
            <rich:tabPanel>
                <rich:tab  header="基本信息">
                    <h:panelGroup id="instock">
                        <rich:toolbar id="tolbar" itemSeparator="grid">
                            <rich:toolbarGroup>

                                <a4j:commandButton value="新建"
                                                   execute="@this"
                                                   action="#{contractBean.add}"
                                                   render="tolbar,mainEditGrid"/>

                                <a4j:commandButton value="修改" action="#{contractBean.update}"
                                                   execute="@this"
                                                   disabled="#{contractBean.addOrUpdate
                                                               or contractBean.mainInfo.number eq ''
                                                               or not(contractBean.mainInfo.flowMark eq '0'
                                                               or contractBean.mainInfo.flowMark eq '-1')}"
                                                   render="tolbar,mainEditGrid"/>

                                <a4j:commandButton value="删除" action="#{contractBean.delete}"
                                                   disabled="#{contractBean.addOrUpdate
                                                               or contractBean.mainInfo.number eq ''
                                                               or not(contractBean.mainInfo.flowMark eq '0'
                                                               or contractBean.mainInfo.flowMark eq '-1')}"
                                                   render="tolbar,mainEditGrid"
                                                   onclick="return confirm('确定删除！');"/>

                                <a4j:commandButton value="保存"
                                                   action="#{contractBean.checkSave}"
                                                   disabled="#{!contractBean.editStatus
                                                               or not(contractBean.mainInfo.flowMark eq '0'
                                                               or contractBean.mainInfo.flowMark eq '-1')}"
                                                   render="tolbar,mainEditGrid"/>

                                <a4j:commandButton value="取消"
                                                   action="#{contractBean.cancel}"
                                                   disabled="#{not(contractBean.mainInfo.flowMark eq '0'
                                                               or contractBean.mainInfo.flowMark eq '-1')}"
                                                   immediate="true"
                                                   render="tolbar,mainEditGrid"/>

                                <h:commandButton value="提交"
                                                 action="#{contractBean.submit}"                                                   
                                                 disabled="#{contractBean.editStatus
                                                             or empty contractBean.mainInfo.number
                                                             or not(contractBean.mainInfo.flowMark eq '0'
                                                             or contractBean.mainInfo.flowMark eq '-1')}"/>

                                <h:commandButton value="生效"
                                                 action="#{contractBean.check}"                                                   
                                                 disabled="#{contractBean.editStatus
                                                             or empty contractBean.mainInfo.number
                                                             or contractBean.mainInfo.flowMark eq '100'}"/>                                

                                <h:commandButton value="失效"
                                                 action="#{contractBean.unCheck}"                     
                                                 disabled="#{contractBean.editStatus
                                                             or empty contractBean.mainInfo.number
                                                             or not(contractBean.mainInfo.flowMark eq '100')}"/>

                                <h:commandButton value="打印"
                                                 action="#{contractBean.print}"
                                                 disabled="true"
                                                 immediate="true"/>

                                <a4j:commandButton value="参照采购"
                                                   onclick="#{rich:component('catePanel')}.show();"
                                                   render="catePopuPanel"
                                                   disabled="#{true or !contractBean.editStatus
                                                               or not (contractBean.mainInfo.flowMark eq '0'
                                                               or contractBean.mainInfo.flowMark eq '-1')}"/>
                            </rich:toolbarGroup>

                        </rich:toolbar>

                        <h:panelGrid id="mainEditGrid"
                                     columns="4"
                                     width="100%"
                                     styleClass="mainForm"
                                     border="0">

                            <h:outputLabel value="编号:" for="number"/>
                            <h:inputText  id="number" disabled="#{true}" value="#{contractBean.mainInfo.number}"/>

                            <h:outputLabel value="类别：" for="typeName"/>
                            <h:panelGroup id="typeName">
                                <h:inputText onclick="#{rich:component('typePanel')}.show();"
                                             disabled="#{!contractBean.editStatus}"
                                             value="#{contractBean.mainInfo.contractTypeName}"/>
                                <h:inputHidden value="#{contractBean.mainInfo.contractTypeCode}"
                                               rendered="#{contractBean.editStatus}"
                                               requiredMessage="请选择合同类别"/>
                            </h:panelGroup>

                            <h:outputLabel value="收付款类型："/>
                            <h:panelGroup id="isPayCon">
                                <h:inputText value="收款" readonly="true"
                                             rendered="#{contractBean.mainInfo.isPayCon eq 0}"/>
                                <h:inputText value="付款" readonly="true"
                                             rendered="#{contractBean.mainInfo.isPayCon eq 1}"/>
                                <h:inputText value="" readonly="true"
                                             rendered="#{not(contractBean.mainInfo.isPayCon eq 0 or contractBean.mainInfo.isPayCon eq 1)}"/>
                            </h:panelGroup>

                            <h:outputLabel value="名称：" for="cname"/>
                            <h:inputText  id="cname" disabled="#{!contractBean.editStatus}"
                                          value="#{contractBean.mainInfo.cname}"
                                          required="true" requiredMessage="合同名称，不能为空！"/>

                            <h:outputLabel value="签订日期" for="orderdate"/>
                            <h:panelGroup>
                                <rich:calendar id="orderdate"
                                               value="#{contractBean.mainInfo.orderdate}"
                                               disabled="#{!contractBean.editStatus}"
                                               locale="Locale.CHINA"
                                               popup="true"
                                               datePattern="yyyy-MM-dd"
                                               showApplyButton="false"
                                               style="width:200px"
                                               required="true" requiredMessage="签订日期，不能为空！"/>
                            </h:panelGroup>

                            <h:outputLabel value="开始日期：" for="start"/>
                            <h:panelGroup>
                                <rich:calendar id="start" value="#{contractBean.mainInfo.start}"
                                               disabled="#{!contractBean.editStatus}"
                                               locale="Locale.CHINA"
                                               popup="true"
                                               datePattern="yyyy-MM-dd"
                                               showApplyButton="false"
                                               style="width:200px"
                                               required="true" requiredMessage="开始日期，不能为空！"/>
                            </h:panelGroup>

                            <h:outputLabel value="截止日期：" for="deadline"/>
                            <h:panelGroup>
                                <rich:calendar id="deadline"  value="#{contractBean.mainInfo.deadline}"
                                               disabled="#{!contractBean.editStatus}"
                                               locale="Locale.CHINA"
                                               popup="true"
                                               datePattern="yyyy-MM-dd"
                                               showApplyButton="false"
                                               style="width:200px"
                                               required="true" requiredMessage="截止日期，不能为空！"/>
                            </h:panelGroup>

                            <h:outputLabel value="质保日期：" for="warranty"/>
                            <h:panelGroup>
                                <rich:calendar id="warranty" value="#{contractBean.mainInfo.warranty}"
                                               disabled="#{!contractBean.editStatus}"
                                               locale="Locale.CHINA"
                                               popup="true"
                                               datePattern="yyyy-MM-dd"
                                               showApplyButton="false"
                                               style="width:200px"
                                               required="true" requiredMessage="质保日期，不能为空！"/>
                            </h:panelGroup>

                            <h:outputLabel value="甲方：" for="nameA"/>
                            <h:panelGroup id="nameA">
                                <a4j:commandLink execute="@this" onclick="#{rich:component('partnerPanel')}.show();"
                                                 disabled="#{contractBean.mainInfo.isPayCon eq null
                                                             or contractBean.mainInfo.isPayCon eq '1'}">
                                    <h:inputText disabled="#{!contractBean.editStatus}"
                                                 value="#{contractBean.mainInfo.nameA}"/>
                                </a4j:commandLink>
                            </h:panelGroup>

                            <h:outputLabel value="乙方：" for="nameB"/>
                            <h:panelGroup id="nameB">
                                <a4j:commandLink execute="@this" onclick="#{rich:component('partnerPanel')}.show();"
                                                 disabled="#{contractBean.mainInfo.isPayCon eq null or contractBean.mainInfo.isPayCon eq '0'}">
                                    <h:inputText disabled="#{!contractBean.editStatus}"
                                                 value="#{contractBean.mainInfo.nameB}"/>
                                </a4j:commandLink>
                            </h:panelGroup>

                            <h:outputLabel value="甲方法人：" for="nameAstand"/>
                            <h:inputText  id="nameAstand" disabled="#{!contractBean.editStatus}"
                                          value="#{contractBean.mainInfo.nameAstand}"/>

                            <h:outputLabel value="乙方法人：" for="nameBstand"/>
                            <h:inputText  id="nameBstand" disabled="#{!contractBean.editStatus}"
                                          value="#{contractBean.mainInfo.nameBstand}"/>

                            <h:outputLabel value="地点：" for="address"/>
                            <h:inputText  id="address" disabled="#{!contractBean.editStatus}"
                                          value="#{contractBean.mainInfo.address}"
                                          required="true" requiredMessage="地点，不能为空！"/>

                            <h:outputLabel value="标的：" for="target"/>
                            <h:inputText  id="target" disabled="#{!contractBean.editStatus}"
                                          value="#{contractBean.mainInfo.target}"
                                          required="true" requiredMessage="标的，不能为空！"/>

                            <h:outputLabel value="质保金：" for="quality_margin"/>
                            <h:inputText id="quality_margin"
                                         disabled="#{!contractBean.editStatus}"
                                         value="#{contractBean.mainInfo.quality_margin}"
                                         required="true" requiredMessage="质保金，不能为空！">
                            </h:inputText>

                            <h:outputLabel value="违约金：" for="penalty"/>
                            <h:inputText  id="penalty" disabled="#{!contractBean.editStatus}"
                                          value="#{contractBean.mainInfo.penalty}"
                                          required="true" requiredMessage="违约金，不能为空！"/>

                            <h:outputLabel value="预算项目：" for="projName"/>
                            <h:panelGroup id="projName">
                                <h:inputText disabled="#{!contractBean.editStatus}"
                                             value="#{contractBean.mainInfo.projName}"
                                             readonly="true"
                                             onclick="#{rich:component('projPanel')}.show();">
                                </h:inputText>
                                <h:inputHidden value="#{contractBean.mainInfo.projCode}"
                                               required="#{contractBean.editStatus}" requiredMessage="预算项目，不能为空！"/> 
                            </h:panelGroup>

                            <h:outputLabel value="备注：" for="other"/>
                            <h:inputText  id="other" disabled="#{!contractBean.editStatus}"
                                          value="#{contractBean.mainInfo.other}"/>

                            <h:outputLabel value="附件：" for="fujian"/>
                            <h:panelGrid id="fujian" columns="2">
                                <a4j:commandLink value="附件上传" action="#{contractBean.uploadDoc}"
                                                 execute="@this" render="docUploadArea"
                                                 disabled="#{!contractBean.editStatus}"
                                                 oncomplete="#{rich:component('fileUploadPanel')}.show();"/>
                                <a4j:commandLink value="附件查看" action="#{contractBean.showDoc}"
                                                 execute="@this" render="docListArea"
                                                 oncomplete="#{rich:component('docListPanel')}.show();"/>
                            </h:panelGrid>
                        </h:panelGrid>
                    </h:panelGroup>
                </rich:tab>

                <rich:tab header="合同内容" >
                    <h:panelGroup id="instocka">
                        <rich:toolbar  itemSeparator="grida">
                            <rich:toolbarGroup>
                                
                                <a4j:commandButton value="编辑" action="#{contractBean.edit_content}"
                                                   disabled="#{contractBean.mainInfo.number eq ''
                                                               or not(contractBean.mainInfo.flowMark eq '0'
                                                               or contractBean.mainInfo.flowMark eq '-1')}"
                                                   onclick="this.disabled = 'true';"
                                                   render="instocka">
                                </a4j:commandButton>

                                <a4j:commandButton value="取消" action="#{contractBean.cancel_content}"
                                                   disabled="#{contractBean.mainInfo.number eq ''
                                                               or not(contractBean.mainInfo.flowMark eq '0'
                                                               or contractBean.mainInfo.flowMark eq '-1')}"
                                                   onclick="this.disabled = 'true';"
                                                   render="instocka">
                                </a4j:commandButton>
                                
                                <a4j:commandButton value="增行" action="#{contractBean.addLine_content}"
                                                   disabled="#{contractBean.mainInfo.number eq ''
                                                               or not(contractBean.mainInfo.flowMark eq '0'
                                                               or contractBean.mainInfo.flowMark eq '-1')
                                                               or not contractBean.editStatus_content}"
                                                   execute="@this" render="instocka"/>
                                <a4j:commandButton value="保存" action="#{contractBean.save_content}"
                                                   disabled="#{contractBean.mainInfo.number eq '' 
                                                               or not(contractBean.mainInfo.flowMark eq '0'
                                                               or contractBean.mainInfo.flowMark eq '-1')
                                                               or not contractBean.editStatus_content}"
                                                   onclick="this.disabled = 'true';"
                                                   render="@this"/>
                                <h:commandButton value="主合同列表" action="#{contractListBean.goback}"/>
                            </rich:toolbarGroup>
                        </rich:toolbar>

                        <h:panelGroup>
                            <h:panelGrid width="100%" columns="1"  style="text-align:center;font-size:12pt;color:red">
                                <h:outputText value="合同【#{contractBean.mainInfo.number}】内容明细" />
                            </h:panelGrid>
                            <div style="height:300px;overflow:auto;">
                                <rich:dataTable id="goodstype"
                                                value="#{contractBean.contentModel}" var="gtmodel"
                                                rowKeyVar="index"
                                                rowClasses="list-row-odd,list-row-even"
                                                headerClass="table-header"
                                                styleClass="formdata"
                                                style="width:100%"
                                                noDataLabel="无数据">
                                    <rich:column style="text-align: center">
                                        <f:facet name="header">行号</f:facet>
                                        <h:outputText value="#{index+1}"/>
                                    </rich:column>

                                    <rich:column id="contentNameRow">
                                        <f:facet name="header">合同内容</f:facet>
                                        <a4j:commandLink execute="@this" onclick="#{rich:component('contentPanel')}.show();"
                                                         disabled="#{not contractBean.editStatus_content}">
                                            <h:inputText id="contentName" size="5" value="#{gtmodel.name}" disabled="#{not contractBean.editStatus_content}"/>
                                            <a4j:param value="#{index}" assignTo="#{contractBean.contentRowIndex}"/>
                                        </a4j:commandLink>
                                        <h:inputHidden value="#{gtmodel.code}"
                                                       required="#{contractBean.editStatus_content}" requiredMessage="合同内容，不能为空"/>
                                    </rich:column>

                                    <rich:column>
                                        <f:facet name="header">数量</f:facet>
                                        <h:inputText value="#{gtmodel.count}" size="5" disabled="#{not contractBean.editStatus_content}">
                                            <a4j:ajax event="keyup" render="total"/>
                                        </h:inputText>
                                    </rich:column>
                                    <rich:column>
                                        <f:facet name="header">单价</f:facet>
                                        <h:inputText value="#{gtmodel.price}" size="5" disabled="#{not contractBean.editStatus_content}">
                                            <a4j:ajax event="keyup" render="total"/>
                                        </h:inputText>
                                    </rich:column>
                                    <rich:column>
                                        <f:facet name="header">总价</f:facet>
                                        <h:outputText id="total" value="#{gtmodel.count * gtmodel.price}"/>
                                    </rich:column>
                                    <rich:column>
                                        <f:facet name="header">技术要求</f:facet>
                                        <h:inputText value="#{gtmodel.tecrequire}" size="5" disabled="#{not contractBean.editStatus_content}"/>
                                    </rich:column>
                                    <rich:column>
                                        <f:facet name="header">备注</f:facet>
                                        <h:inputText value="#{gtmodel.memo}" size="5" disabled="#{not contractBean.editStatus_content}"/>
                                    </rich:column>
                                    <rich:column style="text-align:center;width:30px">
                                        <a4j:commandLink value="删除" 
                                                         disabled="#{not(contractBean.mainInfo.flowMark eq '0'
                                                                     or contractBean.mainInfo.flowMark eq '-1') or not contractBean.editStatus_content}"
                                                         action="#{contractBean.delLine_content}"
                                                         execute="@this" render="goodstype"
                                                         onclick="this.disabled = 'true';">
                                        </a4j:commandLink>
                                    </rich:column>
                                </rich:dataTable>
                            </div>
                        </h:panelGroup>
                    </h:panelGroup>
                </rich:tab>

                <rich:tab  header="合同条款" >
                    <h:panelGroup id="instockb">
                        <rich:toolbar  itemSeparator="gridab">
                            <rich:toolbarGroup>
                                <a4j:commandButton value="编辑" action="#{contractBean.edit_item}"
                                                   disabled="#{contractBean.mainInfo.number eq ''
                                                               or not(contractBean.mainInfo.flowMark eq '0'
                                                               or contractBean.mainInfo.flowMark eq '-1')}"
                                                   onclick="this.disabled = 'true';"
                                                   render="instockb">
                                </a4j:commandButton>

                                <a4j:commandButton value="取消" action="#{contractBean.cancel_item}"
                                                   disabled="#{contractBean.mainInfo.number eq ''
                                                               or not(contractBean.mainInfo.flowMark eq '0'
                                                               or contractBean.mainInfo.flowMark eq '-1')}"
                                                   onclick="this.disabled = 'true';"
                                                   render="instockb">
                                </a4j:commandButton>
                                
                                <a4j:commandButton value="增行" render="instockb" action="#{contractBean.addLine_item}"
                                                   onclick ="message();"
                                                   disabled="#{contractBean.mainInfo.number eq ''
                                                               or not(contractBean.mainInfo.flowMark eq '0'
                                                               or contractBean.mainInfo.flowMark eq '-1')
                                                               or not contractBean.editStatus_item}">
                                </a4j:commandButton>
                                <a4j:commandButton value="保存" action="#{contractBean.save_item}"
                                                   disabled="#{contractBean.mainInfo.number eq ''
                                                               or not(contractBean.mainInfo.flowMark eq '0'
                                                               or contractBean.mainInfo.flowMark eq '-1')
                                                               or not contractBean.editStatus_item}"
                                                   onclick="this.disabled = 'true';"
                                                   render="@this">
                                </a4j:commandButton>
                                <h:commandButton value="主合同列表" action="#{contractListBean.goback}"/>
                            </rich:toolbarGroup>
                        </rich:toolbar>

                        <h:panelGrid width="100%" columns="1"  style="text-align:center;font-size:12pt;color:red">
                            <h:outputText value="合同【#{contractBean.mainInfo.number}】条款信息" />
                        </h:panelGrid>                        
                        <div style="height:300px;overflow:auto;">
                            <rich:dataTable id="goodsterm" value="#{contractBean.itemModel}" var="term"
                                            rowKeyVar="index"
                                            rowClasses="list-row-odd,list-row-even"
                                            headerClass="table-header"
                                            style="width:100%"
                                            noDataLabel="无数据">
                                <rich:column style="text-align: center">
                                    <f:facet name="header">行号</f:facet>
                                    <h:outputText value="#{index+1}" />
                                </rich:column>
                                <rich:column>
                                    <f:facet name="header">主题</f:facet>
                                    <h:inputTextarea value="#{term.topic}" style="width:95%" disabled="#{not contractBean.editStatus_item}"/>
                                </rich:column>
                                <rich:column>
                                    <f:facet name="header">条款</f:facet>
                                    <h:inputTextarea  value="#{term.termtype}" style="width:95%" disabled="#{not contractBean.editStatus_item}"/>
                                </rich:column>
                                <rich:column>
                                    <f:facet name="header">备注</f:facet>
                                    <h:inputTextarea value="#{term.other}" style="width:95%" disabled="#{not contractBean.editStatus_item}"/>
                                </rich:column>
                                <rich:column style="text-align:center;width:30px">
                                    <a4j:commandLink value="删除" action="#{contractBean.delLine_item}"
                                                     disabled="#{not(contractBean.mainInfo.flowMark eq '0'
                                                                 or contractBean.mainInfo.flowMark eq '-1')
                                                                 or not contractBean.editStatus_item}"
                                                     render="goodsterm" onclick="this.disabled = 'true';">
                                    </a4j:commandLink>
                                </rich:column>
                            </rich:dataTable>
                        </div>
                    </h:panelGroup>
                </rich:tab>

                <rich:tab  header="收付款计划" >
                    <h:panelGroup id="payInformation">
                        <rich:toolbar  itemSeparator="grid">
                            <rich:toolbarGroup>
                                <a4j:commandButton value="编辑" action="#{contractBean.edit_payInfo}"
                                                   disabled="#{contractBean.mainInfo.number eq ''
                                                               or not(contractBean.mainInfo.flowMark eq '0'
                                                               or contractBean.mainInfo.flowMark eq '-1')}"
                                                   onclick="this.disabled = 'true';"
                                                   render="payInformation">
                                </a4j:commandButton>

                                <a4j:commandButton value="取消" action="#{contractBean.cancel_payInfo}"
                                                   disabled="#{contractBean.mainInfo.number eq ''
                                                               or not(contractBean.mainInfo.flowMark eq '0'
                                                               or contractBean.mainInfo.flowMark eq '-1')}"
                                                   onclick="this.disabled = 'true';"
                                                   render="payInformation">
                                </a4j:commandButton>

                                <a4j:commandButton value="增行" action="#{contractBean.addLine_payInfo}"
                                                   onclick="message();"
                                                   render="payInformation"
                                                   disabled="#{contractBean.mainInfo.number eq ''
                                                               or not(contractBean.mainInfo.flowMark eq '0'
                                                               or contractBean.mainInfo.flowMark eq '-1')
                                                               or not contractBean.editStatus_payInfo}">
                                </a4j:commandButton>

                                <a4j:commandButton value="保存" action="#{contractBean.save_payInfo}"
                                                   disabled="#{contractBean.mainInfo.number eq ''
                                                               or not(contractBean.mainInfo.flowMark eq '0'
                                                               or contractBean.mainInfo.flowMark eq '-1')
                                                               or not contractBean.editStatus_payInfo}"
                                                   onclick="this.disabled = 'true';"
                                                   render="payInformation">
                                </a4j:commandButton>

                                <h:commandButton value="主合同列表" action="#{contractListBean.goback}"/>

                            </rich:toolbarGroup>
                        </rich:toolbar>
                        <h:panelGrid width="100%" columns="1"  style="text-align:center;font-size:12pt;color:red">
                            <h:outputText value="合同【#{contractBean.mainInfo.number}】收付款明细" />
                        </h:panelGrid>
                        <div style="height:300px;overflow:auto">
                            <rich:dataTable id="detailTable" value="#{contractBean.payInfoModel}" var="detail"
                                            rowKeyVar="index"
                                            rowClasses="list-row-odd,list-row-even"
                                            headerClass="table-header"
                                            styleClass="formdata"
                                            style="width:100%"
                                            noDataLabel="无数据">
                                <rich:column style="text-align: center">
                                    <f:facet name="header">行号</f:facet>
                                    <h:outputText value="#{index+1}"/>
                                </rich:column>
                                <rich:column>
                                    <f:facet name="header">主题</f:facet>
                                    <h:inputTextarea  value="#{detail.topic}" style="width:95%"
                                                      disabled="#{not contractBean.editStatus_payInfo}"/>
                                </rich:column>
                                <rich:column>
                                    <f:facet name="header">时间</f:facet>
                                    <h:panelGroup id="tb-pt">
                                        <rich:calendar value="#{detail.paytime}"
                                                       locale="zh_CN"
                                                       popup="true"
                                                       datePattern="yyyy-MM-dd"
                                                       inputStyle="width:80%"
                                                       showApplyButton="false"
                                                       disabled="#{not contractBean.editStatus_payInfo}">
                                        </rich:calendar>
                                    </h:panelGroup>
                                </rich:column>
                                <rich:column sortBy="#{detail.money}">
                                    <f:facet name="header">金额(元)</f:facet>
                                    <h:inputText value="#{detail.money}" disabled="#{not contractBean.editStatus_payInfo}">
                                        <a4j:ajax event="blur" execute="@this" render="enough"/>
                                    </h:inputText>
                                </rich:column>
                                <rich:column>
                                    <f:facet name="header">备注</f:facet>
                                    <h:inputText value="#{detail.memo}" disabled="#{not contractBean.editStatus_payInfo}"/>
                                </rich:column>
                                <rich:column style="text-align:center;width:30px">
                                    <a4j:commandLink value="删除" action="#{contractBean.delLine_payInfo}"
                                                     disabled="#{not(contractBean.mainInfo.flowMark eq '0'
                                                                 or contractBean.mainInfo.flowMark eq '-1')
                                                                 or not contractBean.editStatus_payInfo}"
                                                     render="detailTable" onclick="this.disabled = 'true';">
                                    </a4j:commandLink>
                                </rich:column>
                            </rich:dataTable>
                        </div>  

                        <h:outputLabel value="合同余额：" for="enough"/>
                        <h:outputText id="enough" value="#{contractBean.enough}"/>

                        <rich:jQuery selector="#incontractTable tr:odd" query="addClass('odd-row')" />
                        <rich:jQuery selector="#incontractTable tr:even" query="addClass('even-row')" />
                        <rich:jQuery selector="#incontractTable tr"
                                     query="mouseover(function(){jQuery(this).addClass('active-row')})"/>
                        <rich:jQuery selector="#incontractTable tr"
                                     query="mouseout(function(){jQuery(this).removeClass('active-row')})"/>
                    </h:panelGroup>
                </rich:tab>

                <rich:tab  header="其他事项" >
                    <h:panelGroup id="instockc">
                        <rich:toolbar  itemSeparator="gridab">
                            <rich:toolbarGroup>
                                <a4j:commandButton value="编辑" action="#{contractBean.edit_matter}"
                                                   disabled="#{contractBean.mainInfo.number eq ''
                                                               or not(contractBean.mainInfo.flowMark eq '0'
                                                               or contractBean.mainInfo.flowMark eq '-1')}"
                                                   onclick="this.disabled = 'true';"
                                                   render="instockc">
                                </a4j:commandButton>

                                <a4j:commandButton value="取消" action="#{contractBean.cancel_matter}"
                                                   disabled="#{contractBean.mainInfo.number eq ''
                                                               or not(contractBean.mainInfo.flowMark eq '0'
                                                               or contractBean.mainInfo.flowMark eq '-1')}"
                                                   onclick="this.disabled = 'true';"
                                                   render="instockc">
                                </a4j:commandButton>

                                <a4j:commandButton value="增行" action="#{contractBean.addLine_matter}"
                                                   onclick ="message();"
                                                   render="instockc"
                                                   disabled="#{contractBean.mainInfo.number eq ''
                                                               or not(contractBean.mainInfo.flowMark eq '0'
                                                               or contractBean.mainInfo.flowMark eq '-1')
                                                               or not contractBean.editStatus_matter}">
                                </a4j:commandButton>
                                <a4j:commandButton value="保存" action="#{contractBean.save_matter}"
                                                   disabled="#{contractBean.mainInfo.number eq ''
                                                               or not(contractBean.mainInfo.flowMark eq '0'
                                                               or contractBean.mainInfo.flowMark eq '-1')
                                                               or not contractBean.editStatus_matter}"
                                                   onclick="this.disabled = 'true';"
                                                   render="instockc">
                                </a4j:commandButton>
                                <h:commandButton value="主合同列表" action="#{contractListBean.goback}"/>
                            </rich:toolbarGroup>
                        </rich:toolbar>
                        <h:panelGrid width="100%" columns="1"  style="text-align:center;font-size:12pt;color:red">
                            <h:outputText value="合同【#{contractBean.mainInfo.number}】其他事项" />
                        </h:panelGrid>
                        <div style="height:300px;overflow:auto;">
                            <rich:dataTable id="matter" value="#{contractBean.matterModel}" var="term"
                                            rowKeyVar="index"
                                            rowClasses="list-row-odd,list-row-even"
                                            headerClass="table-header"
                                            style="width:100%"
                                            noDataLabel="无数据">
                                <rich:column style="text-align: center">
                                    <f:facet name="header">行号</f:facet>
                                    <h:outputText value="#{index+1}" />
                                </rich:column>
                                <rich:column>
                                    <f:facet name="header">主题</f:facet>
                                    <h:inputTextarea  value="#{term.topic}" style="width:95%" disabled="#{not contractBean.editStatus_matter}"/>
                                </rich:column>
                                <rich:column>
                                    <f:facet name="header">其他事项</f:facet>
                                    <h:inputTextarea value="#{term.matter}" style="width:95%" disabled="#{not contractBean.editStatus_matter}"/>
                                </rich:column>
                                <rich:column>
                                    <f:facet name="header">备注</f:facet>
                                    <h:inputTextarea value="#{term.memo}" style="width:95%" disabled="#{not contractBean.editStatus_matter}"/>
                                </rich:column>
                                <rich:column style="text-align:center;width:30px">
                                    <a4j:commandLink value="删除" action="#{contractBean.delLine_matter}"
                                                     disabled="#{not(contractBean.mainInfo.flowMark eq '0'
                                                                 or contractBean.mainInfo.flowMark eq '-1')
                                                                 or not contractBean.editStatus_matter}"
                                                     render="matter" onclick="this.disabled = 'true';">
                                    </a4j:commandLink>
                                </rich:column>
                            </rich:dataTable>
                        </div>
                    </h:panelGroup>
                </rich:tab>

                <rich:tab  header="违约责任" >
                    <h:panelGroup id="instockd">
                        <rich:toolbar  itemSeparator="gridab">
                            <rich:toolbarGroup>

                                <a4j:commandButton value="编辑" action="#{contractBean.edit_duty}"
                                                   disabled="#{contractBean.mainInfo.number eq ''
                                                               or not(contractBean.mainInfo.flowMark eq '0'
                                                               or contractBean.mainInfo.flowMark eq '-1')}"
                                                   onclick="this.disabled = 'true';"
                                                   render="instockd">
                                </a4j:commandButton>

                                <a4j:commandButton value="取消" action="#{contractBean.cancel_duty}"
                                                   disabled="#{contractBean.mainInfo.number eq ''
                                                               or not(contractBean.mainInfo.flowMark eq '0'
                                                               or contractBean.mainInfo.flowMark eq '-1')}"
                                                   onclick="this.disabled = 'true';"
                                                   render="instockd">
                                </a4j:commandButton>

                                <a4j:commandButton value="增行"  action="#{contractBean.addLine_duty}"
                                                   onclick ="message();"
                                                   render="instockd"
                                                   disabled="#{contractBean.mainInfo.number eq ''
                                                               or not(contractBean.mainInfo.flowMark eq '0'
                                                               or contractBean.mainInfo.flowMark eq '-1')
                                                               or not contractBean.editStatus_duty}">
                                </a4j:commandButton>
                                <a4j:commandButton value="保存" action="#{contractBean.save_duty}"
                                                   disabled="#{contractBean.mainInfo.number eq ''
                                                               or not(contractBean.mainInfo.flowMark eq '0'
                                                               or contractBean.mainInfo.flowMark eq '-1')
                                                               or not contractBean.editStatus_duty}"
                                                   onclick="this.disabled = 'true';"
                                                   render="@this">
                                </a4j:commandButton>
                                <h:commandButton value="主合同列表" action="#{contractListBean.goback}"/>
                            </rich:toolbarGroup>
                        </rich:toolbar>
                        <h:panelGrid width="100%" columns="1"  style="text-align:center;font-size:12pt;color:red">
                            <h:outputText value="合同【#{contractBean.mainInfo.number}】违约责任" />
                        </h:panelGrid>
                        <div style="height:300px;overflow:auto;">
                            <rich:dataTable id="duty" value="#{contractBean.dutyModel}" var="term"
                                            rowKeyVar="index"
                                            rowClasses="list-row-odd,list-row-even"
                                            headerClass="table-header"
                                            style="width:100%"
                                            noDataLabel="无数据">
                                <rich:column style="text-align: center">
                                    <f:facet name="header">行号</f:facet>
                                    <h:outputText value="#{index+1}"/>
                                </rich:column>
                                <rich:column>
                                    <f:facet name="header">违约责任</f:facet>
                                    <h:inputTextarea value="#{term.duty}"
                                                     disabled="#{not contractBean.editStatus_duty}"
                                                     style="width:95%"/>
                                </rich:column>
                                <rich:column>
                                    <f:facet name="header">备注</f:facet>
                                    <h:inputTextarea value="#{term.memo}"
                                                     disabled="#{not contractBean.editStatus_duty}"
                                                     style="width:95%"/>
                                </rich:column>
                                <rich:column style="text-align:center;width:30px">
                                    <a4j:commandLink value="删除" action="#{contractBean.delLine_duty}"
                                                     disabled="#{not(contractBean.mainInfo.flowMark eq '0'
                                                                 or contractBean.mainInfo.flowMark eq '-1')
                                                                 or not contractBean.editStatus_duty}"
                                                     render="duty" onclick="this.disabled = 'true';">
                                    </a4j:commandLink>
                                </rich:column>
                            </rich:dataTable>
                        </div>
                    </h:panelGroup>
                </rich:tab>

                <rich:tab header="补充合同">
                    <h:panelGroup>
                        <rich:toolbar itemSeparator="grid">
                            <rich:toolbarGroup>
                                <h:commandButton value ="添加补充合同信息"
                                                 action="#{contractInitBean.addSupplyContract(contractBean.mainInfo.number)}"
                                                 disabled="#{contractBean.mainInfo.number eq ''}"/>
                                <h:commandButton value="主合同列表" action="#{contractListBean.goback}"/>
                            </rich:toolbarGroup>
                        </rich:toolbar>
                        <h:panelGrid width="100%" columns="1"  style="text-align:center;font-size:12pt;color:red">
                            <h:outputText value="合同【#{contractBean.mainInfo.number}】补充合同列表" />
                        </h:panelGrid>
                        <h:panelGroup id="tableEdit">
                            <rich:dataScroller for="conotherTable" execute="@this" render="tableEdit"/>
                            <div style="width:100%;overflow:auto;">
                                <rich:dataTable id="conotherTable"
                                                value="#{contractBean.otherModel}" var="incontract"
                                                rowClasses="list-row-odd,list-row-even"
                                                headerClass="table-header"
                                                noDataLabel="无数据"
                                                style="width:1200px;margin-bottom: 5px;">
                                    <rich:column style="text-align: center">
                                        <h:commandLink value="查看"
                                                       action="#{contractInitBean.showSupplyContract(incontract.number)}"
                                                       immediate="true"/>
                                    </rich:column>
                                    <rich:column sortBy="#{incontract.number}">
                                        <f:facet name="header">补充合同编号</f:facet>
                                        <h:outputText value="#{incontract.number}"/>
                                    </rich:column>
                                    <rich:column sortBy="#{incontract.cname}">
                                        <f:facet name="header">名称</f:facet>
                                        <h:outputText value="#{incontract.cname}"/>
                                    </rich:column>
                                    <rich:column sortBy="#{incontract.contractTypeName}">
                                        <f:facet name="header">合同类别</f:facet>
                                        <h:outputText value="#{incontract.contractTypeName}"/>
                                    </rich:column>
                                    <rich:column sortBy="#{incontract.address}">
                                        <f:facet name="header">地点</f:facet>
                                        <h:outputText value="#{incontract.address}"/>
                                    </rich:column>
                                    <rich:column sortBy="#{incontract.orderdate}">
                                        <f:facet name="header">签订日期</f:facet>
                                        <h:outputText value="#{incontract.orderdate}">
                                            <f:convertDateTime dateStyle="medium"/>
                                        </h:outputText>
                                    </rich:column>
                                    <rich:column sortBy="#{incontract.start}">
                                        <f:facet name="header">开始日期</f:facet>
                                        <h:outputText value="#{incontract.start}">
                                            <f:convertDateTime dateStyle="medium"/>
                                        </h:outputText>
                                    </rich:column>
                                    <rich:column sortBy="#{incontract.deadline}">
                                        <f:facet name="header">截止日期</f:facet>
                                        <h:outputText value="#{incontract.deadline}">
                                            <f:convertDateTime dateStyle="medium"/>
                                        </h:outputText>
                                    </rich:column>
                                    <rich:column sortBy="#{incontract.warranty}">
                                        <f:facet name="header">质保日期</f:facet>
                                        <h:outputText value="#{incontract.warranty}">
                                            <f:convertDateTime dateStyle="medium"/>
                                        </h:outputText>
                                    </rich:column>
                                    <rich:column sortBy="#{incontract.nameA}">
                                        <f:facet name="header">甲方</f:facet>
                                        <h:outputText value="#{incontract.nameA}"/>
                                    </rich:column>
                                    <rich:column sortBy="#{incontract.nameAstand}">
                                        <f:facet name="header">甲方法人</f:facet>
                                        <h:outputText value="#{incontract.nameAstand}"/>
                                    </rich:column>
                                    <rich:column sortBy="#{incontract.partner.name}">
                                        <f:facet name="header">乙方</f:facet>
                                        <h:outputText value="#{incontract.partner.name}"/>
                                    </rich:column>
                                    <rich:column sortBy="#{incontract.partner.legalPerson}">
                                        <f:facet name="header">乙方法人</f:facet>
                                        <h:outputText value="#{incontract.partner.legalPerson}"/>
                                    </rich:column>
                                    <rich:column sortBy="#{incontract.target}">
                                        <f:facet name="header">标的</f:facet>
                                        <h:outputText value="#{incontract.target}"/>
                                    </rich:column>
                                    <rich:column sortBy="#{incontract.quality_margin}">
                                        <f:facet name="header">质保金</f:facet>
                                        <h:outputText value="#{incontract.quality_margin}"/>
                                    </rich:column>
                                    <rich:column sortBy="#{incontract.penalty}">
                                        <f:facet name="header">违约金</f:facet>
                                        <h:outputText value="#{incontract.penalty}"/>
                                    </rich:column>
                                    <rich:column sortBy="#{incontract.other}">
                                        <f:facet name="header">其他</f:facet>
                                        <h:outputText value="#{incontract.other}"/>
                                    </rich:column>
                                    <rich:column sortBy="#{incontract.pay}">
                                        <f:facet name="header">付款条件</f:facet>
                                        <h:outputText value="#{incontract.pay}"/>
                                    </rich:column>
                                </rich:dataTable>
                            </div>
                        </h:panelGroup>
                    </h:panelGroup>
                </rich:tab>
            </rich:tabPanel>
        </rich:panel>
    </h:form>

    <rich:popupPanel id="projPanel" autosized="true">
        <f:facet name="header">预算项目</f:facet>
        <f:facet name="controls">
            <h:outputLink value="#" onclick="#{rich:component('projPanel')}.hide();">关闭</h:outputLink>
        </f:facet>
        <h:form>
            <div style="width:400px;height:400px;overflow:auto;">
                <rich:tree value="#{projectBean.rootNode}" var="idept"
                           selectionType="ajax" toggleType="client"
                           selectionChangeListener="#{contractBean.projectTreeSelected}"
                           style="width:300px" render="projName">
                    <rich:treeNode ondblclick="#{rich:component('projPanel')}.hide();">
                        <h:outputText value="[#{idept.data.code}]#{idept.data.name}" />
                    </rich:treeNode>
                </rich:tree>
            </div>
        </h:form>
    </rich:popupPanel>

    <rich:popupPanel id="typePanel" autosized="true">
        <f:facet name="header">合同类别列表</f:facet>
        <f:facet name="controls">
            <h:outputLink value="#" onclick="#{rich:component('typePanel')}.hide();">关闭</h:outputLink>
        </f:facet>
        <h:form>         
            <h:panelGrid id="showIsPayCon" columns="2">                
                类型名称：
                <h:outputText value="#{contractBean.mainInfo.contractTypeName}"/>
                收付款类型：
                <h:outputText value="收款" rendered="#{contractBean.mainInfo.isPayCon eq 0}"/>
                <h:outputText value="付款" rendered="#{contractBean.mainInfo.isPayCon eq 1}"/>
            </h:panelGrid>   
            <hr/>
            <div style="height:400px;overflow:auto;">
                <rich:tree value="#{contractTypeBean.rootNode}" var="idept"
                           selectionType="ajax" toggleType="client"
                           selectionChangeListener="#{contractBean.contractTypeTreeSelected}"
                           style="width:300px" render="typeName,isPayCon,showIsPayCon,nameA,nameB">
                    <rich:treeNode ondblclick="#{rich:component('typePanel')}.hide();">
                        <h:outputText value="[#{idept.data.code}]#{idept.data.name}" />
                    </rich:treeNode>
                </rich:tree>
            </div>
        </h:form>
    </rich:popupPanel>

    <rich:popupPanel id="partnerPanel" width="400" height="300">
        <f:facet name="header">乙方列表</f:facet>
        <f:facet name="controls">
            <h:outputLink value="#" onclick="#{rich:component('partnerPanel')}.hide();">关闭</h:outputLink>
        </f:facet>
        <h:form>
            <rich:extendedDataTable value="#{contractBean.partnerModel}" var="emp"
                                    rowClasses="list-row-odd,list-row-even"
                                    headerClass="table-header" >
                <rich:column>
                    <a4j:commandLink action="#{contractBean.partnerliSelected}"
                                     execute="@this" render="nameA,nameAstand,nameB,nameBstand"
                                     onclick="#{rich:component('partnerPanel')}.hide();">
                        <h:outputText value="选择" />
                    </a4j:commandLink>
                </rich:column>

                <rich:column sortBy="#{emp.id}">
                    <f:facet name="header">
                        <h:panelGroup>
                            <h:outputText value="代码"/>
                        </h:panelGroup>
                    </f:facet>
                    <h:outputText value="#{emp.id}"/>
                </rich:column>
                <rich:column sortBy="#{emp.name}">
                    <f:facet name="header">
                        <h:panelGroup>
                            <h:outputText value="名称"/>
                        </h:panelGroup>
                    </f:facet>
                    <h:outputText value="#{emp.name}"/>
                </rich:column>
                <rich:column sortBy="#{emp.simplename}">
                    <f:facet name="header">
                        <h:panelGroup>
                            <h:outputText value="法人"/>
                        </h:panelGroup>
                    </f:facet>
                    <h:outputText value="#{emp.legalPerson}"/>
                </rich:column>
            </rich:extendedDataTable> 
        </h:form>
    </rich:popupPanel>

    <rich:popupPanel id="contentPanel" autosized="true">
        <f:facet name="header">合同内容列表</f:facet>
        <f:facet name="controls">
            <h:outputLink value="#" onclick="#{rich:component('contentPanel')}.hide();">关闭</h:outputLink>
        </f:facet>
        <h:form>
            <rich:panel>
                <h:panelGrid columns="1">
                    <h:panelGroup>
                        <div style="height:200px;min-width:350px;overflow: auto;">
                            <rich:tree value="#{inventTypeBean.rootNode}" var="idept"
                                       selectionType="ajax" toggleType="client"
                                       selectionChangeListener="#{inventBean.treeSelected}"
                                       style="width:300px"
                                       render="inventGroup">
                                <rich:treeNode>
                                    <h:outputText value="[#{idept.data.code}]#{idept.data.name}" />
                                </rich:treeNode>
                            </rich:tree>
                        </div>
                    </h:panelGroup>

                    <h:panelGroup id="inventGroup">
                        <rich:dataScroller for="dataInputinfo" execute="@this" render="tableGroup"/>
                        <div style="width: 550px;overflow:auto;">
                            <rich:dataTable value="#{inventBean.dataList}" var="dataInput"
                                            rows="5" rowKeyVar="rowKey"
                                            id="dataInputinfo"
                                            styleClass="tableStyle"
                                            style="width:100%;margin-bottom: 5px;"
                                            noDataLabel="无数据！">

                                <f:facet name="header">
                                    <h:outputText value="存货档案" />
                                </f:facet>

                                <rich:column>
                                    <f:facet name="header">
                                        <h:panelGroup>
                                            <h:outputText value="编码"/>
                                        </h:panelGroup>
                                    </f:facet>
                                    <a4j:commandLink value="#{dataInput.id}"
                                                     action="#{contractBean.inventSelected(dataInput.id,dataInput.name)}"
                                                     execute="@this" render="goodstype"
                                                     oncomplete="#{rich:component('contentPanel')}.hide();">
                                    </a4j:commandLink>
                                </rich:column>

                                <rich:column>
                                    <f:facet name="header">
                                        <h:panelGroup>
                                            <h:outputText value="名称"/>
                                        </h:panelGroup>
                                    </f:facet>
                                    <h:outputText  value="#{dataInput.name}" />
                                </rich:column>

                                <rich:column>
                                    <f:facet name="header">
                                        <h:panelGroup>
                                            <h:outputText value="简称"/>
                                        </h:panelGroup>
                                    </f:facet>
                                    <h:outputText  value="#{dataInput.simplename}"/>
                                </rich:column>

                                <rich:column>
                                    <f:facet name="header">
                                        <h:panelGroup>
                                            <h:outputText value="计量单位"/>
                                        </h:panelGroup>
                                    </f:facet>
                                    <h:outputText value="#{dataInput.measure}"/>
                                </rich:column>

                                <rich:column>
                                    <f:facet name="header">
                                        <h:panelGroup>
                                            <h:outputText value="规格"/>
                                        </h:panelGroup>
                                    </f:facet>
                                    <h:outputText value="#{dataInput.model}"/>
                                </rich:column>

                                <rich:column>
                                    <f:facet name="header">
                                        <h:panelGroup>
                                            <h:outputText value="商品描述"/>
                                        </h:panelGroup>
                                    </f:facet>
                                    <h:outputText value="#{dataInput.descri}"/>
                                </rich:column>

                                <rich:column>
                                    <f:facet name="header">
                                        <h:panelGroup>
                                            <h:outputText value="存货类型"/>
                                        </h:panelGroup>
                                    </f:facet>
                                    <h:outputText value="#{dataInput.type.name}"/>
                                </rich:column>

                            </rich:dataTable>
                        </div>
                    </h:panelGroup>
                </h:panelGrid>
            </rich:panel>
        </h:form>
    </rich:popupPanel>


    <rich:popupPanel id="fileUploadPanel" autosized="true">
        <f:facet name="header">附件上传</f:facet>
        <f:facet name="controls">
            <h:outputLink value="#" onclick="#{rich:component('fileUploadPanel')}.hide();">关闭</h:outputLink>
        </f:facet>
        <h:form>
            <rich:panel id="docUploadArea">
                <h:panelGrid columns="2" columnClasses="top,top">
                    <rich:fileUpload fileUploadListener="#{fileUploadBean.listener}"
                                     maxFilesQuantity="#{fileUploadBean.maxAmount}"       
                                     disabled="#{not(fileUploadBean.size le fileUploadBean.maxAmount)}"
                                     serverErrorLabel="上传失败"
                                     sizeExceededLabel="文件太大，无法上传"
                                     clearAllLabel="全部清空"
                                     clearLabel="清空"
                                     addLabel="添加"
                                     doneLabel="完成"
                                     uploadLabel="上传"
                                     deleteLabel="删除"
                                     id="upload">
                        <a4j:ajax event="uploadcomplete" render="info,errmessage" />
                    </rich:fileUpload>
                    <h:panelGroup id="info">
                        <rich:panel bodyClass="info">
                            <f:facet name="header">
                                <h:outputText value="上传成功后的文件信息" />
                            </f:facet>
                            <h:outputText value="当前并未上传.."
                                          rendered="#{fileUploadBean.size==0}" />
                            <div style="max-height:300px;overflow: auto;">
                                <rich:dataGrid columns="1" value="#{fileUploadBean.files}"
                                               var="file" rowKeyVar="row">
                                    <rich:panel bodyClass="rich-laguna-panel-no-header">
                                        <h:panelGrid columns="2">
                                            <a4j:mediaOutput element="img" mimeType="#{file.mime}"
                                                             createContent="#{fileUploadBean.paint}" value="#{row}"
                                                             style="width:100px; height:100px;" cacheable="false">
                                                <f:param value="#{fileUploadBean.timeStamp}" name="time"/>
                                            </a4j:mediaOutput>
                                            <h:panelGrid columns="2">
                                                <h:outputText value="文件名:" />
                                                <h:outputText value="#{file.name}" />
                                                <h:outputText value="文件大小(bytes):" />
                                                <h:outputText value="#{file.length}" />
                                            </h:panelGrid>
                                        </h:panelGrid>
                                    </rich:panel>
                                </rich:dataGrid>
                            </div>
                        </rich:panel>
                        <br/>
                        <a4j:commandButton action="#{fileUploadBean.clearUploadData}"
                                           render="info, upload" value="清除上传的文件信息"
                                           rendered="#{fileUploadBean.size>0}" />
                    </h:panelGroup>
                </h:panelGrid>
            </rich:panel>
        </h:form>
    </rich:popupPanel>


    <rich:popupPanel id="docListPanel" autosized="true">
        <f:facet name="header">附件列表</f:facet>
        <f:facet name="controls">
            <h:outputLink value="#" onclick="#{rich:component('docListPanel')}.hide();">关闭</h:outputLink>
        </f:facet>
        <h:form>
            <rich:panel id="docListArea">
                <div style="width:600px;height: 400px;overflow: auto;">
                    <rich:dataTable value="#{contractBean.curDocList}" var="doc"
                                    rows="10" rowKeyVar="rowKey"
                                    style="width:100%;"
                                    styleClass="stable">
                        <rich:column style="text-align: center;">
                            <f:facet name="header">
                                <h:panelGroup style="white-space: nowrap;">
                                    行号
                                </h:panelGroup>
                            </f:facet>
                            <h:outputText value="#{rowKey+1}"/>
                        </rich:column>
                        <rich:column sortBy="#{doc.title}">
                            <f:facet name="header">
                                <h:panelGroup style="white-space: nowrap;">
                                    <h:outputText value="文档标题"/>
                                </h:panelGroup>
                            </f:facet>
                            <h:outputText value="#{doc.title}"/>
                        </rich:column>
                        <rich:column style="white-space: nowrap;">
                            <f:facet name="header">
                                <h:panelGroup style="white-space: nowrap;">
                                    <h:outputText value="上传日期"/>
                                </h:panelGroup>
                            </f:facet>
                            <h:outputText value="#{doc.uploadDate}">
                                <f:convertDateTime  dateStyle="medium"/>
                            </h:outputText>
                        </rich:column>
                        <rich:column sortBy="#{doc.userName}">
                            <f:facet name="header">
                                <h:panelGroup style="white-space: nowrap;">
                                    <h:outputText value="上传人员"/>
                                </h:panelGroup>
                            </f:facet>
                            <h:outputText value="#{doc.userName}"/>
                        </rich:column>
                        <rich:column sortBy="#{doc.docSize}">
                            <f:facet name="header">
                                <h:panelGroup style="white-space: nowrap;">
                                    <h:outputText value="文件大小"/>
                                </h:panelGroup>
                            </f:facet>
                            <h:outputText value="#{doc.docSize}"/>
                        </rich:column>
                        <rich:column sortBy="#{doc.description}">
                            <f:facet name="header">
                                <h:panelGroup style="white-space: nowrap;">
                                    <h:outputText value="文档描述"/>
                                </h:panelGroup>
                            </f:facet>
                            <h:outputText value="#{doc.description}"/>
                        </rich:column>
                        <rich:column style="white-space: nowrap;">
                            <f:facet name="header">
                                <h:panelGroup>
                                    <h:outputText value="下载"/>
                                </h:panelGroup>
                            </f:facet>
                            <h:commandLink rendered="#{doc.showflag}"
                                           style="text-decoration: none"
                                           action="#{contractBean.downloadDoc(doc)}">
                                <h:outputText value="下载 " rendered="#{doc.showflag}"/>
                            </h:commandLink>
                            <h:outputText value="文档已不存在" rendered="#{doc.showflag==false}"/>
                            <a4j:commandLink action="#{contractBean.deleteDoc(doc.id)}"
                                             execute="@this" render="docListArea"
                                             style="text-decoration: none">
                                <h:outputText value=" 删除"/>
                            </a4j:commandLink>
                        </rich:column>
                        <f:facet name="footer">
                            <rich:dataScroller id="ds"></rich:dataScroller>
                        </f:facet>
                    </rich:dataTable>
                </div>
            </rich:panel>
        </h:form>
    </rich:popupPanel>
</ui:composition>